/*
 * inotify-sync - a simple file synchronizer and file system watcher
 * Copyright (C) 2010-2011, inotify-sync developers and inotify-sync contributors
 * Copyright (C) 2010-2011, Cohesion Network Security Studio
 *
 * inotify-sync is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * inotify-sync is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with inotify-sync; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/*
 * FILE:			ProfileTest.cpp
 * USAGE:			---
 * DESCRIPTION:		---
 * OPTIONS:			---
 * REQUIREMENTS:	---
 * BUGS:			---
 * NOTES:			---
 * AUTHOR:			LI Yiwei (mail:leeyiw@gmail.com)
 * COMPANY:			---
 * VERSION:			1.0
 * CREATED:			Sat Oct  8 12:12:21 CST 2011
 * REVISION:		---
 */

#include "ProfileTest.h"

void
ProfileTest::setUp()
{
	p_profile=0;
}

void
ProfileTest::tearDown()
{
	if(p_profile)
		delete p_profile;
}

CppUnit::Test*
ProfileTest::suite()
{
	CppUnit::TestSuite *suite=new CppUnit::TestSuite("ProfileTest");

	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"testProfile()",
								&ProfileTest::testProfile));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_profile_name()",
								&ProfileTest::test_get_profile_name));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_profile_name()",
								&ProfileTest::test_set_profile_name));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_mode()",
								&ProfileTest::test_get_mode));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_mode()",
								&ProfileTest::test_set_mode));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_log_mode()",
								&ProfileTest::test_get_log_mode));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_log_mode()",
								&ProfileTest::test_set_log_mode));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_log_path()",
								&ProfileTest::test_get_log_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_log_path()",
								&ProfileTest::test_set_log_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_watch_hide()",
								&ProfileTest::test_get_watch_hide));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_watch_hide()",
								&ProfileTest::test_set_watch_hide));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_src_path()",
								&ProfileTest::test_get_src_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_src_path()",
								&ProfileTest::test_set_src_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_tmp_path()",
								&ProfileTest::test_get_tmp_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_tmp_path()",
								&ProfileTest::test_set_tmp_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_get_dest_path()",
								&ProfileTest::test_get_dest_path));
	suite->addTest(new CppUnit::TestCaller<ProfileTest>(
								"test_set_dest_path()",
								&ProfileTest::test_set_dest_path));

	return suite;
}


void
ProfileTest::testProfile()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	CPPUNIT_ASSERT_MESSAGE(
				"error when init profile_name",
				p_profile->profile_name=="");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init mode",
				p_profile->mode==0);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init log_mode",
				p_profile->log_mode==0);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init log_path",
				p_profile->log_path=="");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init watch_hide",
				p_profile->watch_hide==0);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init src_path",
				p_profile->src_path=="");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init tmp_path",
				p_profile->tmp_path=="");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init dest_path",
				p_profile->dest_path=="");

	p_profile=new Profile("test_init_profile_name",
							PROFILE_MODE_SYNC,
							LOG_MODE_STD,
							"test_init_log_path",
							NO_WATCH_HIDE,
							"test_init_src_path",
							"test_init_tmp_path",
							"test_init_dest_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init profile_name",
				p_profile->profile_name=="test_init_profile_name");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init mode",
				p_profile->mode==PROFILE_MODE_SYNC);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init log_mode",
				p_profile->log_mode==LOG_MODE_STD);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init log_path",
				p_profile->log_path=="test_init_log_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init watch_hide",
				p_profile->watch_hide==NO_WATCH_HIDE);
	CPPUNIT_ASSERT_MESSAGE(
				"error when init src_path",
				p_profile->src_path=="test_init_src_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init tmp_path",
				p_profile->tmp_path=="test_init_tmp_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when init dest_path",
				p_profile->dest_path=="test_init_dest_path");
}

void
ProfileTest::test_get_profile_name()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->profile_name="test_get_profile_name";
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_profile_name",
				p_profile->get_profile_name()=="test_get_profile_name");
}

void
ProfileTest::test_set_profile_name()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_profile_name("test_set_profile_name");
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_profile_name",
				p_profile->profile_name=="test_set_profile_name");
}

void
ProfileTest::test_get_mode()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->mode=PROFILE_MODE_WATCH;
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_mode",
				p_profile->get_mode()==PROFILE_MODE_WATCH);
}

void
ProfileTest::test_set_mode()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_mode(PROFILE_MODE_SYNC);
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_mode",
				p_profile->mode==PROFILE_MODE_SYNC);
}

void
ProfileTest::test_get_log_mode()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->log_mode=LOG_MODE_STD;
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_log_mode",
				p_profile->get_log_mode()==LOG_MODE_STD);
}

void
ProfileTest::test_set_log_mode()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_mode(LOG_MODE_STD);
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_mode",
				p_profile->mode==LOG_MODE_STD);
}

void
ProfileTest::test_get_log_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->log_path="test_get_log_path";
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_log_path",
				p_profile->get_log_path()=="test_get_log_path");
}

void
ProfileTest::test_set_log_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_log_path("test_set_log_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_log_path",
				p_profile->log_path=="test_set_log_path");
}

void
ProfileTest::test_get_watch_hide()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->watch_hide=WATCH_HIDE;
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_watch_hide",
				p_profile->get_watch_hide()==WATCH_HIDE);
}

void
ProfileTest::test_set_watch_hide()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_watch_hide(NO_WATCH_HIDE);
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_watch_hide",
				p_profile->watch_hide==NO_WATCH_HIDE);
}

void
ProfileTest::test_get_src_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->src_path="test_get_src_path";
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_src_path",
				p_profile->get_src_path()=="test_get_src_path");
}

void
ProfileTest::test_set_src_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_src_path("test_set_src_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_src_path",
				p_profile->src_path=="test_set_src_path");
}

void
ProfileTest::test_get_tmp_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->tmp_path="test_get_tmp_path";
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_tmp_path",
				p_profile->get_tmp_path()=="test_get_tmp_path");
}

void
ProfileTest::test_set_tmp_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_tmp_path("test_set_tmp_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_tmp_path",
				p_profile->tmp_path=="test_set_tmp_path");
}

void
ProfileTest::test_get_dest_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->dest_path="test_get_dest_path";
	CPPUNIT_ASSERT_MESSAGE(
				"error when get_dest_path",
				p_profile->get_dest_path()=="test_get_dest_path");
}

void
ProfileTest::test_set_dest_path()
{
	if(p_profile)
		delete p_profile;
	p_profile=new Profile();
	p_profile->set_dest_path("test_set_dest_path");
	CPPUNIT_ASSERT_MESSAGE(
				"error when set_dest_path",
				p_profile->dest_path=="test_set_dest_path");
}
